layui.use(['table', 'form', 'layedit', 'laydate', 'jquery', 'layer'], function () {
    var table = layui.table
        , form = layui.form
        // ,layer = layui.layer
        , layer = parent.layer === undefined ? layui.layer : parent.layer
        , laydate = layui.laydate
        , $ = layui.jquery;

    //自定义验证规则
    form.verify({
        password: [/(.+){6,12}$/, '密码必须6到12位']
    });
    form.on('submit(demo1)', function (data) {

        $.ajax({
            type: "post",
            url: ctx + "/user/updatePwd.do",
            dataType: "json",
            // contentType:"application/json",
            async: false,
            // data: JSON.stringify(data.field),
            data: data.field,
            success: function (res) {
                if (res.resultCode == 10000) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.layer.msg(res.msg, {icon: 1});
                    $.get(ctx + "/user/loginout.do");
                    window.location = ctx + '/user/loginPage.do';
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            },
        });
    })


});